package com.shqcjd.sinopecdemomobile.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shqcjd.sinopecdemomobile.R;
import com.shqcjd.sinopecdemomobile.model.pojo.EquipmentInfoInspectBean;

import java.util.List;

public class EqumentInfoAdapter extends BaseAdapter {

    private List<EquipmentInfoInspectBean.ListBean> mList;
    private LayoutInflater inflater;

    public EqumentInfoAdapter(List<EquipmentInfoInspectBean.ListBean> mList, Context context) {
        this.mList = mList;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mList == null ? 0 : (mList.size()>4?4:mList.size());
    }

    @Override
    public Object getItem(int position) {
        return null;
    }


    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //加载布局为一个视图
        View view = inflater.inflate(R.layout.item_equipment_info_inspection, null);
        TextView tv_item_equipment_info_code = view.findViewById(R.id.tv_item_equipment_info_code);
        TextView tv_item_equipment_info_order = view.findViewById(R.id.tv_item_equipment_info_order);
        TextView tv_item_equipment_info_person = view.findViewById(R.id.tv_item_equipment_info_person);
        TextView tv_item_equipment_info_time = view.findViewById(R.id.tv_item_equipment_info_time);
        tv_item_equipment_info_code.setText(mList.get(position).task_code);
        tv_item_equipment_info_order.setText(mList.get(position).task_time);
        tv_item_equipment_info_person.setText(mList.get(position).user_name);
        tv_item_equipment_info_time.setText(mList.get(position).check_date);
        return view;
    }

}